<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qvector2d.cpp -->
  <title>QVector2D Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QVector2D</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QVector2D Class</h1>
<!-- $$$QVector2D-brief -->
<p>The QVector2D class represents a vector or vertex in 2D space. <a href="#details">More...</a></p>
<!-- @@@QVector2D -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QVector2D&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 4.6</td></tr></table></div><p>This class was introduced in Qt 4.6.</p>
<ul>
<li><a href="qvector2d-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D-6">QVector2D</a></b>(const QVector4D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D-5">QVector2D</a></b>(const QVector3D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D-4">QVector2D</a></b>(const QPointF &amp;<i>point</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D-3">QVector2D</a></b>(const QPoint &amp;<i>point</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D-2">QVector2D</a></b>(float <i>xpos</i>, float <i>ypos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#QVector2D">QVector2D</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#distanceToLine">distanceToLine</a></b>(const QVector2D &amp;<i>point</i>, const QVector2D &amp;<i>direction</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#distanceToPoint">distanceToPoint</a></b>(const QVector2D &amp;<i>point</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#length">length</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#lengthSquared">lengthSquared</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#normalize">normalize</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#normalized">normalized</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#setX">setX</a></b>(float <i>x</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#setY">setY</a></b>(float <i>y</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#toPoint">toPoint</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#toPointF">toPointF</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector3D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#toVector3D">toVector3D</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector4D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#toVector4D">toVector4D</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#x">x</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#y">y</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-QVariant">operator QVariant</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2a-eq">operator*=</a></b>(float <i>factor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2a-eq-1">operator*=</a></b>(const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2b-eq">operator+=</a></b>(const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator--eq">operator-=</a></b>(const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2f-eq">operator/=</a></b>(float <i>divisor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector2D &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2f-eq-1">operator/=</a></b>(const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-5b-5d">operator[]</a></b>(int <i>i</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-5b-5d-1">operator[]</a></b>(int <i>i</i>) const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#dotProduct">dotProduct</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#qFuzzyCompare">qFuzzyCompare</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-not-eq">operator!=</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2a">operator*</a></b>(float <i>factor</i>, const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2a-1">operator*</a></b>(const QVector2D &amp;<i>vector</i>, float <i>factor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2a-2">operator*</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2b">operator+</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-">operator-</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator--1">operator-</a></b>(const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2f">operator/</a></b>(const QVector2D &amp;<i>vector</i>, float <i>divisor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QVector2D </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-2f-1">operator/</a></b>(const QVector2D &amp;<i>vector</i>, const QVector2D &amp;<i>divisor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-lt-lt-7">operator&lt;&lt;</a></b>(QDataStream &amp;<i>stream</i>, const QVector2D &amp;<i>vector</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-eq-eq">operator==</a></b>(const QVector2D &amp;<i>v1</i>, const QVector2D &amp;<i>v2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qvector2d.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>stream</i>, QVector2D &amp;<i>vector</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QVector2D-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The QVector2D class can also be used to represent vertices in 2D space. We therefore do not need to provide a separate vertex class.</p>
</div>
<p><b>See also </b><a href="qvector3d.html">QVector3D</a>, <a href="qvector4d.html">QVector4D</a>, and <a href="qquaternion.html">QQuaternion</a>.</p>
<!-- @@@QVector2D -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QVector2D$$$QVector2DconstQVector4D& -->
<h3 class="fn" id="QVector2D-6"><a name="QVector2D-6"></a>QVector2D::<span class="name">QVector2D</span>(const <span class="type"><a href="qvector4d.html">QVector4D</a></span> &amp;<i>vector</i>)</h3>
<p>Constructs a vector with x and y coordinates from a 3D <i>vector</i>. The z and w coordinates of <i>vector</i> are dropped.</p>
<p><b>See also </b><a href="qvector2d.html#toVector4D">toVector4D</a>().</p>
<!-- @@@QVector2D -->
<!-- $$$QVector2D$$$QVector2DconstQVector3D& -->
<h3 class="fn" id="QVector2D-5"><a name="QVector2D-5"></a>QVector2D::<span class="name">QVector2D</span>(const <span class="type"><a href="qvector3d.html">QVector3D</a></span> &amp;<i>vector</i>)</h3>
<p>Constructs a vector with x and y coordinates from a 3D <i>vector</i>. The z coordinate of <i>vector</i> is dropped.</p>
<p><b>See also </b><a href="qvector2d.html#toVector3D">toVector3D</a>().</p>
<!-- @@@QVector2D -->
<!-- $$$QVector2D$$$QVector2DconstQPointF& -->
<h3 class="fn" id="QVector2D-4"><a name="QVector2D-4"></a>QVector2D::<span class="name">QVector2D</span>(const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>point</i>)</h3>
<p>Constructs a vector with x and y coordinates from a 2D <i>point</i>.</p>
<!-- @@@QVector2D -->
<!-- $$$QVector2D$$$QVector2DconstQPoint& -->
<h3 class="fn" id="QVector2D-3"><a name="QVector2D-3"></a>QVector2D::<span class="name">QVector2D</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>point</i>)</h3>
<p>Constructs a vector with x and y coordinates from a 2D <i>point</i>.</p>
<!-- @@@QVector2D -->
<!-- $$$QVector2D$$$QVector2Dfloatfloat -->
<h3 class="fn" id="QVector2D-2"><a name="QVector2D-2"></a>QVector2D::<span class="name">QVector2D</span>(<span class="type">float</span> <i>xpos</i>, <span class="type">float</span> <i>ypos</i>)</h3>
<p>Constructs a vector with coordinates (<i>xpos</i>, <i>ypos</i>).</p>
<!-- @@@QVector2D -->
<!-- $$$QVector2D[overload1]$$$QVector2D -->
<h3 class="fn" id="QVector2D"><a name="QVector2D"></a>QVector2D::<span class="name">QVector2D</span>()</h3>
<p>Constructs a null vector, i.e&#x2e; with coordinates (0, 0).</p>
<!-- @@@QVector2D -->
<!-- $$$distanceToLine[overload1]$$$distanceToLineconstQVector2D&constQVector2D& -->
<h3 class="fn" id="distanceToLine"><a name="distanceToLine"></a><span class="type">float</span> QVector2D::<span class="name">distanceToLine</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>point</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>direction</i>) const</h3>
<p>Returns the distance that this vertex is from a line defined by <i>point</i> and the unit vector <i>direction</i>.</p>
<p>If <i>direction</i> is a null vector, then it does not define a line. In that case, the distance from <i>point</i> to this vertex is returned.</p>
<p>This function was introduced in Qt 5.1.</p>
<p><b>See also </b><a href="qvector2d.html#distanceToPoint">distanceToPoint</a>().</p>
<!-- @@@distanceToLine -->
<!-- $$$distanceToPoint[overload1]$$$distanceToPointconstQVector2D& -->
<h3 class="fn" id="distanceToPoint"><a name="distanceToPoint"></a><span class="type">float</span> QVector2D::<span class="name">distanceToPoint</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>point</i>) const</h3>
<p>Returns the distance from this vertex to a point defined by the vertex <i>point</i>.</p>
<p>This function was introduced in Qt 5.1.</p>
<p><b>See also </b><a href="qvector2d.html#distanceToLine">distanceToLine</a>().</p>
<!-- @@@distanceToPoint -->
<!-- $$$dotProduct[overload1]$$$dotProductconstQVector2D&constQVector2D& -->
<h3 class="fn" id="dotProduct"><a name="dotProduct"></a><code>[static] </code><span class="type">float</span> QVector2D::<span class="name">dotProduct</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns the dot product of <i>v1</i> and <i>v2</i>.</p>
<!-- @@@dotProduct -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QVector2D::<span class="name">isNull</span>() const</h3>
<p>Returns <code>true</code> if the x and y coordinates are set to 0.0, otherwise returns <code>false</code>.</p>
<!-- @@@isNull -->
<!-- $$$length[overload1]$$$length -->
<h3 class="fn" id="length"><a name="length"></a><span class="type">float</span> QVector2D::<span class="name">length</span>() const</h3>
<p>Returns the length of the vector from the origin.</p>
<p><b>See also </b><a href="qvector2d.html#lengthSquared">lengthSquared</a>() and <a href="qvector2d.html#normalized">normalized</a>().</p>
<!-- @@@length -->
<!-- $$$lengthSquared[overload1]$$$lengthSquared -->
<h3 class="fn" id="lengthSquared"><a name="lengthSquared"></a><span class="type">float</span> QVector2D::<span class="name">lengthSquared</span>() const</h3>
<p>Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.</p>
<p><b>See also </b><a href="qvector2d.html#length">length</a>() and <a href="qvector2d.html#dotProduct">dotProduct</a>().</p>
<!-- @@@lengthSquared -->
<!-- $$$normalize[overload1]$$$normalize -->
<h3 class="fn" id="normalize"><a name="normalize"></a><span class="type">void</span> QVector2D::<span class="name">normalize</span>()</h3>
<p>Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.</p>
<p><b>See also </b><a href="qvector2d.html#length">length</a>() and <a href="qvector2d.html#normalized">normalized</a>().</p>
<!-- @@@normalize -->
<!-- $$$normalized[overload1]$$$normalized -->
<h3 class="fn" id="normalized"><a name="normalized"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> QVector2D::<span class="name">normalized</span>() const</h3>
<p>Returns the normalized unit vector form of this vector.</p>
<p>If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.</p>
<p><b>See also </b><a href="qvector2d.html#length">length</a>() and <a href="qvector2d.html#normalize">normalize</a>().</p>
<!-- @@@normalized -->
<!-- $$$setX[overload1]$$$setXfloat -->
<h3 class="fn" id="setX"><a name="setX"></a><span class="type">void</span> QVector2D::<span class="name">setX</span>(<span class="type">float</span> <i>x</i>)</h3>
<p>Sets the x coordinate of this point to the given <i>x</i> coordinate.</p>
<p><b>See also </b><a href="qvector2d.html#x">x</a>() and <a href="qvector2d.html#setY">setY</a>().</p>
<!-- @@@setX -->
<!-- $$$setY[overload1]$$$setYfloat -->
<h3 class="fn" id="setY"><a name="setY"></a><span class="type">void</span> QVector2D::<span class="name">setY</span>(<span class="type">float</span> <i>y</i>)</h3>
<p>Sets the y coordinate of this point to the given <i>y</i> coordinate.</p>
<p><b>See also </b><a href="qvector2d.html#y">y</a>() and <a href="qvector2d.html#setX">setX</a>().</p>
<!-- @@@setY -->
<!-- $$$toPoint[overload1]$$$toPoint -->
<h3 class="fn" id="toPoint"><a name="toPoint"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QVector2D::<span class="name">toPoint</span>() const</h3>
<p>Returns the <a href="../qtcore/qpoint.html">QPoint</a> form of this 2D vector.</p>
<p><b>See also </b><a href="qvector2d.html#toPointF">toPointF</a>() and <a href="qvector2d.html#toVector3D">toVector3D</a>().</p>
<!-- @@@toPoint -->
<!-- $$$toPointF[overload1]$$$toPointF -->
<h3 class="fn" id="toPointF"><a name="toPointF"></a><span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> QVector2D::<span class="name">toPointF</span>() const</h3>
<p>Returns the <a href="../qtcore/qpointf.html">QPointF</a> form of this 2D vector.</p>
<p><b>See also </b><a href="qvector2d.html#toPoint">toPoint</a>() and <a href="qvector2d.html#toVector3D">toVector3D</a>().</p>
<!-- @@@toPointF -->
<!-- $$$toVector3D[overload1]$$$toVector3D -->
<h3 class="fn" id="toVector3D"><a name="toVector3D"></a><span class="type"><a href="qvector3d.html">QVector3D</a></span> QVector2D::<span class="name">toVector3D</span>() const</h3>
<p>Returns the 3D form of this 2D vector, with the z coordinate set to zero.</p>
<p><b>See also </b><a href="qvector2d.html#toVector4D">toVector4D</a>() and <a href="qvector2d.html#toPoint">toPoint</a>().</p>
<!-- @@@toVector3D -->
<!-- $$$toVector4D[overload1]$$$toVector4D -->
<h3 class="fn" id="toVector4D"><a name="toVector4D"></a><span class="type"><a href="qvector4d.html">QVector4D</a></span> QVector2D::<span class="name">toVector4D</span>() const</h3>
<p>Returns the 4D form of this 2D vector, with the z and w coordinates set to zero.</p>
<p><b>See also </b><a href="qvector2d.html#toVector3D">toVector3D</a>() and <a href="qvector2d.html#toPoint">toPoint</a>().</p>
<!-- @@@toVector4D -->
<!-- $$$x[overload1]$$$x -->
<h3 class="fn" id="x"><a name="x"></a><span class="type">float</span> QVector2D::<span class="name">x</span>() const</h3>
<p>Returns the x coordinate of this point.</p>
<p><b>See also </b><a href="qvector2d.html#setX">setX</a>() and <a href="qvector2d.html#y">y</a>().</p>
<!-- @@@x -->
<!-- $$$y[overload1]$$$y -->
<h3 class="fn" id="y"><a name="y"></a><span class="type">float</span> QVector2D::<span class="name">y</span>() const</h3>
<p>Returns the y coordinate of this point.</p>
<p><b>See also </b><a href="qvector2d.html#setY">setY</a>() and <a href="qvector2d.html#x">x</a>().</p>
<!-- @@@y -->
<!-- $$$operator QVariant[overload1]$$$operator QVariant -->
<h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QVector2D::<span class="name">operator QVariant</span>() const</h3>
<p>Returns the 2D vector as a <a href="../qtcore/qvariant.html">QVariant</a>.</p>
<!-- @@@operator QVariant -->
<!-- $$$operator*=[overload1]$$$operator*=float -->
<h3 class="fn" id="operator-2a-eq"><a name="operator-2a-eq"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator*=</span>(<span class="type">float</span> <i>factor</i>)</h3>
<p>Multiplies this vector's coordinates by the given <i>factor</i>, and returns a reference to this vector.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2f-eq">operator/=</a>().</p>
<!-- @@@operator*= -->
<!-- $$$operator*=$$$operator*=constQVector2D& -->
<h3 class="fn" id="operator-2a-eq-1"><a name="operator-2a-eq-1"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator*=</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Multiplies the components of this vector by the corresponding components in <i>vector</i>.</p>
<!-- @@@operator*= -->
<!-- $$$operator+=[overload1]$$$operator+=constQVector2D& -->
<h3 class="fn" id="operator-2b-eq"><a name="operator-2b-eq"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator+=</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Adds the given <i>vector</i> to this vector and returns a reference to this vector.</p>
<p><b>See also </b><a href="qvector2d.html#operator--eq">operator-=</a>().</p>
<!-- @@@operator+= -->
<!-- $$$operator-=[overload1]$$$operator-=constQVector2D& -->
<h3 class="fn" id="operator--eq"><a name="operator--eq"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator-=</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Subtracts the given <i>vector</i> from this vector and returns a reference to this vector.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2b-eq">operator+=</a>().</p>
<!-- @@@operator-= -->
<!-- $$$operator/=[overload1]$$$operator/=float -->
<h3 class="fn" id="operator-2f-eq"><a name="operator-2f-eq"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator/=</span>(<span class="type">float</span> <i>divisor</i>)</h3>
<p>Divides this vector's coordinates by the given <i>divisor</i>, and returns a reference to this vector.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2a-eq">operator*=</a>().</p>
<!-- @@@operator/= -->
<!-- $$$operator/=$$$operator/=constQVector2D& -->
<h3 class="fn" id="operator-2f-eq-1"><a name="operator-2f-eq-1"></a><span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;QVector2D::<span class="name">operator/=</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Divides the components of this vector by the corresponding components in <i>vector</i>.</p>
<p>This function was introduced in Qt 5.5.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2a-eq">operator*=</a>().</p>
<!-- @@@operator/= -->
<!-- $$$operator[][overload1]$$$operator[]int -->
<h3 class="fn" id="operator-5b-5d"><a name="operator-5b-5d"></a><span class="type">float</span> &amp;QVector2D::<span class="name">operator[]</span>(<span class="type">int</span> <i>i</i>)</h3>
<p>Returns the component of the vector at index position <i>i</i> as a modifiable reference.</p>
<p><i>i</i> must be a valid index position in the vector (i.e&#x2e;, 0 &lt;= <i>i</i> &lt; 2).</p>
<p>This function was introduced in Qt 5.2.</p>
<!-- @@@operator[] -->
<!-- $$$operator[]$$$operator[]int -->
<h3 class="fn" id="operator-5b-5d-1"><a name="operator-5b-5d-1"></a><span class="type">float</span> QVector2D::<span class="name">operator[]</span>(<span class="type">int</span> <i>i</i>) const</h3>
<p>Returns the component of the vector at index position <i>i</i>.</p>
<p><i>i</i> must be a valid index position in the vector (i.e&#x2e;, 0 &lt;= <i>i</i> &lt; 2).</p>
<p>This function was introduced in Qt 5.2.</p>
<!-- @@@operator[] -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qFuzzyCompare[overload1]$$$qFuzzyCompareconstQVector2D&constQVector2D& -->
<h3 class="fn" id="qFuzzyCompare"><a name="qFuzzyCompare"></a><span class="type">bool</span> <span class="name">qFuzzyCompare</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns <code>true</code> if <i>v1</i> and <i>v2</i> are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.</p>
<!-- @@@qFuzzyCompare -->
<!-- $$$operator!=[overload1]$$$operator!=constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> <span class="name">operator!=</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns <code>true</code> if <i>v1</i> is not equal to <i>v2</i>; otherwise returns <code>false</code>. This operator uses an exact floating-point comparison.</p>
<!-- @@@operator!= -->
<!-- $$$operator*[overload1]$$$operator*floatconstQVector2D& -->
<h3 class="fn" id="operator-2a"><a name="operator-2a"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator*</span>(<span class="type">float</span> <i>factor</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Returns a copy of the given <i>vector</i>, multiplied by the given <i>factor</i>.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2a-eq">QVector2D::operator*=</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQVector2D&float -->
<h3 class="fn" id="operator-2a-1"><a name="operator-2a-1"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>, <span class="type">float</span> <i>factor</i>)</h3>
<p>Returns a copy of the given <i>vector</i>, multiplied by the given <i>factor</i>.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2a-eq">QVector2D::operator*=</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-2a-2"><a name="operator-2a-2"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Multiplies the components of <i>v1</i> by the corresponding components in <i>v2</i>.</p>
<!-- @@@operator* -->
<!-- $$$operator+[overload1]$$$operator+constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-2b"><a name="operator-2b"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator+</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns a <a href="qvector2d.html">QVector2D</a> object that is the sum of the given vectors, <i>v1</i> and <i>v2</i>; each component is added separately.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2b-eq">QVector2D::operator+=</a>().</p>
<!-- @@@operator+ -->
<!-- $$$operator-[overload1]$$$operator-constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-"><a name="operator-"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator-</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns a <a href="qvector2d.html">QVector2D</a> object that is formed by subtracting <i>v2</i> from <i>v1</i>; each component is subtracted separately.</p>
<p><b>See also </b><a href="qvector2d.html#operator--eq">QVector2D::operator-=</a>().</p>
<!-- @@@operator- -->
<!-- $$$operator-$$$operator-constQVector2D& -->
<h3 class="fn" id="operator--1"><a name="operator--1"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator-</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>This is an overloaded function.</p>
<p>Returns a <a href="qvector2d.html">QVector2D</a> object that is formed by changing the sign of the components of the given <i>vector</i>.</p>
<p>Equivalent to <code>QVector2D(0,0) - vector</code>.</p>
<!-- @@@operator- -->
<!-- $$$operator/[overload1]$$$operator/constQVector2D&float -->
<h3 class="fn" id="operator-2f"><a name="operator-2f"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator/</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>, <span class="type">float</span> <i>divisor</i>)</h3>
<p>Returns the <a href="qvector2d.html">QVector2D</a> object formed by dividing all three components of the given <i>vector</i> by the given <i>divisor</i>.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2f-eq">QVector2D::operator/=</a>().</p>
<!-- @@@operator/ -->
<!-- $$$operator/$$$operator/constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-2f-1"><a name="operator-2f-1"></a>const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> <span class="name">operator/</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>divisor</i>)</h3>
<p>Returns the <a href="qvector2d.html">QVector2D</a> object formed by dividing components of the given <i>vector</i> by a respective components of the given <i>divisor</i>.</p>
<p>This function was introduced in Qt 5.5.</p>
<p><b>See also </b><a href="qvector2d.html#operator-2f-eq">QVector2D::operator/=</a>().</p>
<!-- @@@operator/ -->
<!-- $$$operator<<$$$operator<<QDataStream&constQVector2D& -->
<h3 class="fn" id="operator-lt-lt-7"><a name="operator-lt-lt-7"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Writes the given <i>vector</i> to the given <i>stream</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator==[overload1]$$$operator==constQVector2D&constQVector2D& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> <span class="name">operator==</span>(const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v1</i>, const <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>v2</i>)</h3>
<p>Returns <code>true</code> if <i>v1</i> is equal to <i>v2</i>; otherwise returns <code>false</code>. This operator uses an exact floating-point comparison.</p>
<!-- @@@operator== -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QVector2D& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, <span class="type"><a href="qvector2d.html#QVector2D">QVector2D</a></span> &amp;<i>vector</i>)</h3>
<p>Reads a 2D vector from the given <i>stream</i> into the given <i>vector</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
